//
//  JMNavigationController.m
//  Pods
//
//  Created by Zhuangyh on 16/1/30.
//
//

#import "JMNavigationController.h"

@interface JMNavigationController ()

@end

@implementation JMNavigationController

#pragma mark 一个类只会调用一次
+ (void)initialize
{
    // 1.取出设置主题的对象
    UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedIn:[JMNavigationController class], nil];
    
#ifdef DYSLLYJ
    //navBar.barTintColor = UIColorFromRGB(33, 48, 74);
    navBar.barTintColor = UIColorFromHexStr(@"#21304c");
    navBar.backgroundColor = UIColorFromHexStr(@"#21304c");
    navBar.tintColor = UIColorFromHexStr(@"#21304c");
    navBar.alpha = 1.0f;
#else
    [navBar setBackgroundImage:[UIImage imageNamed:@"naviBar"] forBarMetrics:UIBarMetricsDefault];
#endif
//    kDYBarWidth = [UIScreen mainScreen].bounds.size.width;
    
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -20)forBarMetrics:UIBarMetricsDefault];
    
    //view----背景色
    UITableView *tableview = [UITableView appearance];
//    tableview.backgroundColor = UIColorFromHexStr(@"#293c5f");

    
    //    //修改导航条上的UIBarButtonItem
    //    UIBarButtonItem *appearance = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];
    //
    //    //设置导航栏的字体包括backBarButton和leftBarButton，rightBarButton的字体
    //    NSDictionary *textAttributes = @{UITextAttributeFont: [UIFont systemFontOfSize:18],
    //                                     UITextAttributeTextColor: [UIColor blueColor],
    //                                     UITextAttributeTextShadowColor: [UIColor whiteColor],
    //                                     UITextAttributeTextShadowOffset: [NSValue valueWithCGSize:CGSizeMake(1, 1)]};
    //
    //    [appearance setTitleTextAttributes:textAttributes forState:1];//forState为0时为下正常状态，为1时为点击状态。
    //
    //
    ////    //修改leftBarButton，rightBarButton背景效果
    ////    [appearance setBackgroundImage:[UIImage imageNamed:@"backBtn.png"]
    ////                          forState:UIControlStateNormal
    ////                             style:UIBarButtonItemStyleBordered
    ////                        barMetrics:UIBarMetricsDefault];
    //
    //
    //    //backBarButton需要单独设置背景效果。只能在ios6.0以后才能用
    //    [appearance setBackButtonBackgroundImage:[UIImage imageNamed:@"backBtn.png"]
    //                                    forState:UIControlStateNormal
    //                                  barMetrics:UIBarMetricsDefault];
    //
    //    [appearance setBackButtonTitlePositionAdjustment:UIOffsetMake( -100, -100)
    //                                       forBarMetrics:UIBarMetricsDefault];
    //    [appearance setBackButtonBackgroundVerticalPositionAdjustment:-12 forBarMetrics:UIBarMetricsDefault];
    
    
    
    
    //        // 设置导航栏的渐变色为白色（iOS7中返回箭头的颜色变为这个颜色：白色）
    //        navBar.tintColor = [UIColor whiteColor];
    
    //    // 3.设置导航栏标题颜色为白色
    //    [navBar setTitleTextAttributes:@{
    //                                     NSForegroundColorAttributeName : [UIColor whiteColor]
    //                                     }];
    //
    //    // 4.设置导航栏按钮文字颜色为白色
    //    [barItem setTitleTextAttributes:@{
    //                                      NSForegroundColorAttributeName : [UIColor whiteColor],
    //                                      NSFontAttributeName : [UIFont systemFontOfSize:13]
    //                                      } forState:UIControlStateNormal];
    
    //获取应用程序中所有的导航条
    //    UINavigationBar *bar = [UINavigationBar appearance];
    //    [bar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:240/255.0 alpha:1.0]];
    //    NSDictionary *dict = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18 weight:bold]};
    //    [bar setTitleTextAttributes:dict];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
